diff options
| author | Armand Philippot <git@armandphilippot.com> | 2022-02-01 15:15:55 +0100 |
|---|---|---|
| committer | Armand Philippot <git@armandphilippot.com> | 2022-02-01 15:15:55 +0100 |
| commit | 1e370817560c905a0a3520e245c317f308b6a5e7 (patch) | |
| tree | f5a1e2c3b8ddbff2cb4d94eff82830388158e4c9 /src/pages/article/[slug].tsx | |
| parent | 8f8a3957b5d3b33bafaa0a6afe4187f75d6dd2b7 (diff) | |
chore: add a new settings to handle prism theme from toolbar
Diffstat (limited to 'src/pages/article/[slug].tsx')
| -rw-r--r-- | src/pages/article/[slug].tsx | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/pages/article/[slug].tsx b/src/pages/article/[slug].tsx index 1799fb0..d0ea68a 100644 --- a/src/pages/article/[slug].tsx +++ b/src/pages/article/[slug].tsx @@ -21,6 +21,7 @@ import { useEffect } from 'react'; import { useIntl } from 'react-intl'; import { Blog, BlogPosting, Graph, WebPage } from 'schema-dts'; import '@utils/plugins/prism-color-scheme'; +import { usePrismTheme } from '@utils/providers/prism'; const SingleArticle: NextPageWithLayout<ArticleProps> = ({ post }) => { const { @@ -61,6 +62,15 @@ const SingleArticle: NextPageWithLayout<ArticleProps> = ({ post }) => { translateCopyButton(locale, intl); }, [intl, locale]); + const { setCodeBlocks } = usePrismTheme(); + + useEffect(() => { + const allPre: NodeListOf<HTMLPreElement> = document.querySelectorAll( + 'pre[data-prismjs-color-scheme' + ); + setCodeBlocks(allPre); + }, [setCodeBlocks, router.asPath]); + const webpageSchema: WebPage = { '@id': `${articleUrl}`, '@type': 'WebPage', |
